<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鞋子的购买</title>
</head>
<body style="text-align: center;">
    <img src="./image/3.jpg" style="width: 400px;" alt="">
    <div class="price">价格:<span>99.80</span></div>
    <div class="num">数量: <input type="number" min="0" style="width:35px;" value="0"></div>
    <div class="total-price">总价:<span>0.00</span></div>
    <button onclick="buyGoods()">购买</button>
    <script>
        function buyGoods(){
            let num=document.querySelector("input").value;
            let price=document.querySelector(".price>span").innerHTML;
            let totalprice=num*price;
            document.querySelector(".total-price>span").innerHTML=totalprice.toFixed(2)
            console.log(totalprice.toFixed(2))
            console.log(document.querySelector(".price").innerText)
            console.log(document.querySelector(".price").innerHTML)
            alert("购买成功,总价为"+totalprice.toFixed(2))
        }
    </script>
</body>
</html>